home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / libcnews / strsave.c < prev    next >
C/C++ Source or Header  |  1989-07-03  |  468b  |  24 lines

  1. /*
  2.  * strsave - like strdup, but error if can't allocate
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include "libc.h"
  8. #include "news.h"
  9.  
  10. /*
  11.  * Copy "s" into malloced memory, if any is available.
  12.  * If not, unlock the news system, print a message and exit,
  13.  * else return the address of the malloced memory.
  14.  */
  15. char *
  16. strsave(s)
  17. register char *s;
  18. {
  19.     register char *news =nemalloc((unsigned)strlen(s)+1); /* include NUL */
  20.  
  21.     (void) strcpy(news, s);
  22.     return news;
  23. }
  24.